package com.devsoft.foodfrenzy;

import org.andengine.entity.sprite.TiledSprite;
import com.badlogic.gdx.physics.box2d.Body;

public class Pan {
	private int position;
	private int rotation;
	private boolean type; //normal pan or double_pan
	private TiledSprite image;
	private Body body;
	
	public Pan(int pos, int rot, boolean t, TiledSprite img){
		this.position = pos;
		this.rotation = rot;
		this.type = t;
		this.image = img;
		image.setCurrentTileIndex(this.rotation);
	}
	
	public int getPos(){
		return position;
	}
	
	public int getRot(){
		return rotation;
	}
	
	public boolean getType(){
		return type;
	}
	
	public void setPos(int pos){
		this.position = pos;
	}
	
	public void setRot(int rot){
		this.rotation = rot;
	}
	
	public void setType(boolean t){
		this.type = t;
	}
	
	public TiledSprite getSprite(){
		return image;
	}
	
	public void setBody(Body body)
	{
		this.body = body;
	}
	
	public Body getBody()
	{
		return body;
	}
	
	public void changeSprite(int index){
		this.image.setCurrentTileIndex(index);
	}
	
	public void rotate(int index){
		this.image.setCurrentTileIndex(index);
		if(type)
		{
		  if(index == 0){
			this.getBody().setTransform(
        			this.getBody().getWorldCenter().x - 6.9f, 
        			this.getBody().getWorldCenter().y, 
        			0.0f);
		  }
		  else if(index == 1){
			this.getBody().setTransform(
        			this.getBody().getWorldCenter().x + 6.9f, 
        			this.getBody().getWorldCenter().y, 
        			0.0f);
		  }
		}
		else
		{
			if(index == 0){
				this.getBody().setTransform(
	        			this.getBody().getWorldCenter().x + 7.4f, 
	        			this.getBody().getWorldCenter().y, 
	        			0.0f);
			  }
			  else if(index == 1){
				this.getBody().setTransform(
	        			this.getBody().getWorldCenter().x - 7.4f, 
	        			this.getBody().getWorldCenter().y, 
	        			0.0f);
			  }
		}
	}

}
